package com.sh.data.engine.domain.datadev.flink.model.domain;

import com.sh.data.engine.repository.dao.datadev.entity.FlinkNodeConfigEntity;
import lombok.Data;

import java.util.Date;
import java.util.Objects;

@Data
public class FlinkResourceDomain {
    /**
     * 主键
     */
    private Long id;

    /**
     * 项目id
     */
    private Long projectId;

    /**
     * 节点id
     */
    private Long nodeId;

    /**
     * 资源路径
     */
    private String path;

    /**
     * 文件名称
     */
    private String fileName;

    /**
     * 发布状态 0-未发布 1-发布
     */
    private Integer isPublished;

    /**
     * 创建人id
     */
    private String userId;

    /**
     * 修改人id
     */
    private String modifyUserId;

    /**
     * 发布人id
     */
    private String publishUserId;

    /**
     * 发布时间
     */
    private Date publishTime;

    /**
     * 描述
     */
    private String remark;

    /**
     * 是否是最新的记录
     */
    private Integer isActive;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 资源名称
     */
    private String resourceName;

    public void init(FlinkNodeConfigEntity entity) {
        this.id = entity.getId();
        this.projectId = entity.getProjectId();
        this.nodeId = entity.getNodeId();
        this.path =
            Objects.nonNull(entity.getResourceConfig()) ? entity.getResourceConfig().getPath() : "";
        this.fileName =
            Objects.nonNull(entity.getResourceConfig()) ? entity.getResourceConfig().getFileName() : "";
        this.isPublished = entity.getIsPublished();
        this.userId = entity.getCreatorId();
        this.modifyUserId = entity.getUpdaterId();
        this.publishUserId = entity.getPublisherId();
        this.remark = entity.getRemark();
        this.isActive = entity.getIsActive();
        this.createTime = entity.getCreateTime();
        this.updateTime = entity.getUpdateTime();
        this.resourceName = entity.getResourceConfig().getResourceName();
    }
}
